//
//  SchoolController.m
//  diaoyuren
//
//  Created by 钓鱼人 on 15/12/18.
//  Copyright © 2015年 game. All rights reserved.
//

#import "SchoolController.h"
#import "AppDelegate.h"
#import "WMPageController.h"
#import "NewestController.h"
#import "PrimerController.h"
#import "SkillController.h"
#import "VideoController.h"
#import "BaitController.h"
#import "WayController.h"
#import "SeaViewController.h"
#import "FishBaitController.h"
#import "GearController.h"
#import "IformationCtrl.h"
#import "CatesModel.h"
#import "SchollSearchController.h"
@interface SchoolController ()
{
    CatesModel *_catesModel;
    NSMutableArray *_CatesAry;//导航菜单文字标签数组
}
@end

@implementation SchoolController
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.app.myTabBar.tabBar.hidden = NO;
    self.navigationController.navigationBarHidden = YES;
     [UIApplication sharedApplication].statusBarStyle = 1;
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
   _CatesAry= [NSMutableArray array];
    
    //传递标签数据
    for (CatesModel *model in _Model.cates) {
        [_CatesAry addObject:model.name];
    }
    self.pageController = [self defaultController];

    [self.view addSubview:self.pageController.view];
    [self addChildViewController:self.pageController];
    
  [self LinViewWhithRcet:CGRectMake(0, 73, SCREEN_WIDTH, 1)];
    
 UIButton *bnt= [self CreatBntWhithRect:CGRectMake(SCREEN_WIDTH*0.86, 35, SCREEN_WIDTH*0.09, 35) AndType:UIButtonTypeCustom AndBntImgName:@"btn-search-grey" AndTitle:@""];
    bnt.adjustsImageWhenDisabled = NO;
    bnt.adjustsImageWhenHighlighted = NO;
    bnt.imageEdgeInsets = UIEdgeInsetsMake(0, 15, 0, -10);
    
    [bnt addTarget:self action:@selector(SchoolSearchAction) forControlEvents:UIControlEventTouchUpInside];
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screen_width, 25)];
    view.backgroundColor  = mainColor;
    [self.view addSubview:view];
    
}

-(void)SchoolSearchAction{
    SchollSearchController *schoolSearch = [SchollSearchController new];
    [self.navigationController pushViewController:schoolSearch animated:YES];
}

#pragma mark--控制器数组
-(NSArray *)PagecontrollersAry{
    
    return @[[NewestController class],[PrimerController class],[VideoController class],[SkillController class],[BaitController class],[FishBaitController class],[WayController class],[SeaViewController class],[GearController class],[IformationCtrl class]];
}
#pragma mark---控制器所对应的标题数组
-(NSArray *)TitlesAry{

    return @[@"最新",@"入门",@"视频",@"技巧",@"渔获",@"饵料",@"路亚",@"海钓",@"渔具",@"资讯"];//;_CatesAry;
}

-(WMPageController *)defaultController{
    
    NSMutableArray *viewControllers =[NSMutableArray array];
    NSMutableArray *titles = [NSMutableArray array];
    
        [viewControllers addObjectsFromArray:[self PagecontrollersAry]];
        [titles addObjectsFromArray:[self TitlesAry]];

WMPageController *pageVC = [[WMPageController alloc] initWithViewControllerClasses:viewControllers andTheirTitles:titles];
    
    pageVC.menuViewStyle = WMMenuViewStyleLine;
    pageVC.titleSizeNormal = 20;
    pageVC.titleSizeSelected = 20;
    pageVC.menuHeight = 74;
    pageVC.menuWidth = SCREEN_WIDTH*0.9;
    pageVC.menuX = 0;
    
    pageVC.menuItemWidth = SCREEN_WIDTH*0.19;
    pageVC.menuBGColor = [UIColor whiteColor];
    pageVC.titleColorNormal = [UIColor grayColor];
    pageVC.titleColorSelected = [UIColor colorWithRed:55.f/255.f green:178.f/255.f blue:16.f/255.f alpha:1];
    pageVC.pageAnimatable = YES;
    pageVC.bounces = NO;
    
#pragma mark---传值-----
//    NSArray * arr = @[@"杀杀杀",@"杀杀杀",@"杀杀杀"];
//    pageVC.values = @[arr];
//    pageVC.keys = @[@"jjfly"];
////    NSLog(@"%@", pageVC.values);
    
    return pageVC;
}

//-(void)didReceiveMemoryWarning{
//    
//    [super didReceiveMemoryWarning];//即使没有显示在window上，也不会自动的将self.view释放。
//    
//    if ([self.view window] == nil) {
//        
//        self.view = nil;// 目的是再次进入时能够重新加载调用viewDidLoad函数。
//        
//    }
//}
@end
